package cn.udinghuo.model.voucher.freight;

import com.fasterxml.jackson.annotation.JsonSetter;

import org.springframework.util.Assert;
import javax.persistence.Entity;
import javax.persistence.Lob;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.Column;
import java.util.Map;
import java.util.HashMap;
import cn.udinghuo.core.domain.entity.BaseAuditTenant;	
import java.math.BigDecimal;	
import cn.udinghuo.model.voucher.freight.ConditionTypeEnum;	
import cn.udinghuo.model.voucher.freight.FreePostageScopeEnum;	
import cn.udinghuo.model.voucher.freight.FreightRule;	
import java.time.LocalDateTime;	
import cn.udinghuo.model.voucher.freight.TerminalEnum;	
import cn.udinghuo.core.domain.entity.Comment;
import cn.udinghuo.core.domain.entity.ita.CacheKey;

/**
 * @author xufla
 *	条件包邮设置
 */
@Entity
@Table(name="conditionsfreepostage")
public class ConditionsFreePostage extends BaseAuditTenant<Long>  {

	private static final long serialVersionUID = -1L;
	/**
	* 终端类型terminal
	*/
	@Comment(value="终端类型")
	@Column(name="iTerminal")
	private Short terminal;
	/**
	* 描述memo
	*/
	@Comment(value="描述")
	@Column(name="cMemo", length = 255)
	private String memo;
	/**
	* 有效期开始时间startDate
	*/
	@Comment(value="有效期开始时间")
	@Column(name="dStartDate")
	private LocalDateTime startDate;
	/**
	* 有效期结束时间endDate
	*/
	@Comment(value="有效期结束时间")
	@Column(name="dEndDate")
	private LocalDateTime endDate;
	/**
	* 条件类型conditionType
	*/
	@Comment(value="条件类型")
	@Column(name="iConditionType")
	private Short conditionType;
	/**
	* 条件值conditionValue
	*/
	@Comment(value="条件值")
	@Column(name="fConditionValue")
	private BigDecimal conditionValue;
	/**
	* 条件单位unit
	*/
	@Comment(value="条件单位")
	@Column(name="fUnit", length = 50)
	private String unit;
	/**
	* 包邮范围freePostageScope
	*/
	@Comment(value="包邮范围")
	@Column(name="iFreePostageScope")
	private Short freePostageScope;
	/**
	* 模板idfreightRuleId
	*/
	@Comment(value="模板id")
	@Column(name="iFreightRuleId")
	private Long freightRuleId;
	public TerminalEnum getTerminal() {
        if(this.terminal == null){
			return null;
		}
		return TerminalEnum.find(this.terminal.intValue());
	}
	@JsonSetter
	public void setTerminal(TerminalEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.terminal = value.getValue();
	}
	
	public void setTerminal(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(TerminalEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.terminal = value;
	}
	
	public String getMemo() {
		return this.memo;
	}
	
	public void setMemo(String value) {
		this.memo = value;
	}
	
	public LocalDateTime getStartDate() {
		return this.startDate;
	}
	
	public void setStartDate(LocalDateTime value) {
		this.startDate = value;
	}
	
	public LocalDateTime getEndDate() {
		return this.endDate;
	}
	
	public void setEndDate(LocalDateTime value) {
		this.endDate = value;
	}
	
	public ConditionTypeEnum getConditionType() {
        if(this.conditionType == null){
			return null;
		}
		return ConditionTypeEnum.find(this.conditionType.intValue());
	}
	@JsonSetter
	public void setConditionType(ConditionTypeEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.conditionType = value.getValue();
	}
	
	public void setConditionType(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(ConditionTypeEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.conditionType = value;
	}
	
	public BigDecimal getConditionValue() {
		return this.conditionValue;
	}
	
	public void setConditionValue(BigDecimal value) {
		this.conditionValue = value;
	}
	
	public String getUnit() {
		return this.unit;
	}
	
	public void setUnit(String value) {
		this.unit = value;
	}
	
	public FreePostageScopeEnum getFreePostageScope() {
        if(this.freePostageScope == null){
			return null;
		}
		return FreePostageScopeEnum.find(this.freePostageScope.intValue());
	}
	@JsonSetter
	public void setFreePostageScope(FreePostageScopeEnum value) {
		Assert.notNull(value, "enum value is invalid value!");
		this.freePostageScope = value.getValue();
	}
	
	public void setFreePostageScope(Short value) {
		Assert.notNull(value,"enum value is invalid value!");
		Assert.notNull(FreePostageScopeEnum.find(value.intValue()),"enum value is invalid value!"); 
		this.freePostageScope = value;
	}
	
	public Long getFreightRuleId() {
		return this.freightRuleId;
	}
	
	public void setFreightRuleId(Long value) {
		this.freightRuleId = value;
	}
	
    
	public FreightRule getFreightRule() {
		return (FreightRule) this.getTransient("freightRule");
	}
	
	public void setFreightRule(FreightRule value) {
		this.putTransient("freightRule",value);
	}
	
}
